 TcsNotebook Component

Properties	Events

Unit

CSNoteBk

Description

The TcsNotebook component is similar to the TTabbedNotebook component but differs in that you can:

Attach the tabs to the top, bottom, left or right of the notebook using the TabOrientation property.

Specify a different bitmap to be displayed on each tab by editing the Pages property.

Specify the color of the selected tab's caption text using the SelectedColor and the color of the unselected tab's caption text using the UnselectedColor.

Specify the color of the notebook and the selected tab using the Color and ParentColor properties.

Specify the color of the unselected tabs using the UnselectedTabColor and UseUnselectedTabColor properties.

Specify the alignment of the tab’s caption text using the TextAlignment property.

Specify the alignment of the tab’s bitmap using the BitmapAlignment property.

Save resources by releasing the handles for the controls on the current page when another page is selected by setting the SaveResources property.

Control the appearance of the tabs/notebook with the CornerSize, MaxTabWidth, RowIndent, SidewaysText, TabHeight properties.

Change the behaviour of the notebook with the AnchoredTabs property.

Easily access the Notebook's Pages property at design time by using the (right click) context menu.

Contact Classic Software if you need support for TcsNotebook.


Properties

ActivePage	SaveResources	UseUnselectedTabColor
AnchoredTabs	SelectedColor
BitmapAlignment	SidewaysText	Run-time only:
CornerSize	TabFont	TabBitmap
MaxTabWidth	TabHeight	TabCaption
PageIndex	TabOrientation	TabPageIndex
Pages	TabsPerRow
ParentTabFont	TextAlignment
RowExtent	UnselectedColor
RowIndent	UnselectedTabColor


Events

OnPageChanged

OnPageChanging

OnTabClick


CSNoteBk Unit

The CSNoteBk unit contains the declaration for the TcsNotebook component and its associated objects.

The following items are declared in the CSNoteBk unit:

Components

TcsNotebook

TcsPage


ActivePage Property

Applies to

TcsNotebook, TNotebook,  TTabbedNotebook component

Declaration

property ActivePage: String;

Description

The ActivePage property determines which page is displayed in the notebook or tabbed notebook control.  The value of ActivePage must be one of the strings contained in the Pages property.


AnchoredTabs Property

Applies to

TcsNotebook component

Declaration

property AnchoredTabs: Boolean;

The AnchoredTabs property determines whether tabs will remain in place when selected or will be brought to the front row.  The default value is False.


BitmapAlignment Property

Applies to

TcsNotebook component

Declaration

property BitmapAlignment: TBitmapAlignment;

Description

The BitmapAlignment property determines the placement of the appropriate bitmap (if specified) on each tab.  Note that the different bitmap alignment options are always regarded as though you are viewing the tab in Top orientation, doing the stated bitmap alignment, and then rotating the tab (but not rotating the bitmap).


TBitmapAlignment Type

Unit

CSNoteBk

Declaration

TBitmapAlignment = (baLeftTop, baCentreTop, baCenterTop, baRightTop, baLeftMiddle, baCentreMiddle, baCenterMiddle, baRightMiddle, baLeftBottom, baCentreBottom, baCenterBottom, baRightBottom, baFit);

Description

TBitmapAlignment defines the possible values of the BitmapAlignment property.


CornerSize Property

Applies to

TcsNotebook component

Declaration

property CornerSize: Integer;

Description

The CornerSize property can be used to alter the size of the corner of each Tab.  The value specified is the amount, in pixels, which is to be cut’ off the corner of the tab.  The CornerSize will always be greater than 0.  Specify a CornerSize value of 1 if you want Win95 style (square) tabs.

Note that in certain situations the control will automatically adjust the CornerSize to prevent inappropriate values relative to the values of the following properties: MaxTabWidth, TabHeight.


MaxTabWidth Property

Applies to

TcsNotebook component

Declaration

property MaxTabWidth: Integer;

Description

The MaxTabWidth property controls the maximum width, in pixels, of each tab.  When set to 0 (the default) the tabs in a row will be sized to spread evenly across the full width of each row.  If you don't want the tabs to ever be wider than a certain amount, for example if each tab has a short caption, you should change MaxTabWidth to the desired value.  Note that you are not specifying the tab's width but the maximum width it can be.  If the tab is narrower than MaxTabWidth (by virtue of the width of the notebook and how many tabs there are per row) the tab's width will not be increased to MaxTabWidth.

Increasing the TabsPerRow property to a value greater than the actual no. of tabs will have a similar effect to increasing MaxTabWidth but with all tabs always in a single row.

Note that in certain situations the control will automatically adjust the MaxTabWidth to prevent inappropriate values relative to the value of the CornerSize property.


PageIndex Property

Applies to

TcsNotebook, TNotebook,  TTabbedNotebook component

Declaration

property PageIndex: Integer;

Description

The PageIndex property determines the current page in the notebook.  Changing the PageIndex value changes the page currently displayed by the control.  The PageIndex value is zero based and will range from 0 up to the number of tabs minus 1, i.e. 0..4 if there are 5 tabs.  Each new page added will be given the next available page number.  Note that if you delete pages the PageIndex values will be re-assigned to the remained tabs, starting from 0 and increasing.

You can also change the current page by using the ActivePage property.


Pages Property

See also	Bitmaps

Applies to

TcsNotebook, TNotebook,  TTabbedNotebook component

Declaration

property Pages: TStrings;

Description

The Pages property contains the captions that identify each page in the notebook.  The control ensures that the captions for each page are unique.  Each caption in Pages will have an associated page which contains the controls for that page.  The bitmap (if specified) for each page is also contained in each page.

To access the actual pages themselves you can use the Objects property of Pages.  Each page, i.e. each item in Objects[], is of type TcsPage.   To access the tab caption for a page you can also use the TabCaption property.  To access the bitmap for a page you can also use the TabBitmap property.


See Also

Add Tab Dialog Box

Edit Tab Dialog Box

TabBitmap

TabCaption

TabPageIndex

TcsNotebook


Bitmaps for TcsNotebook Pages

Normally, the bitmaps for each tab of the TcsNotebook would be specified at design-time using the Notebook Tabs Editor.  However, if you want to assign or change the bitmaps for the tabs at run-time you can do this by using the TabBitmap property.  The following examples show how to do this when the form is first created .  The examples assume that you have added a TcsNotebook component to Form1 and that it is called csNotebook1.  The first example shows how a new bitmap can be assigned to the first tab (page 0) by loading a bitmap file.

Example 1

procedure TForm1.FormCreate(Sender: TObject);

begin

  csNotebook1.TabBitmap[0].LoadFromFile('c:\bitmaps\map.bmp');

end;

The next example shows how a bitmap which has been included in a resource file can be assigned to the first tab.  The bitmap's resouce identifier is 'mybitmap'.

Example 2

procedure TForm1.FormCreate(Sender: TObject);

begin

  csNotebook1.TabBitmap[0].Handle :=

    LoadBitmap(HInstance, 'mybitmap');

end;


ParentTabFont Property

Applies to

TcsNotebook component

Declaration

property ParentTabFont: Boolean;

Description

The ParentTabFont property determines where the notebook looks for the font information for the tabs.  If ParentTabFont is True, the notebook uses the font in its parent component's Font property for the tabs.  If ParentTabFont is False, the notebook uses the TabFont property for the tabs.

Specifying a different TabFont value will automatically set ParentTabFont to False.  Setting ParentTabFont to True automatically sets the notebook's TabFont to the same font as its parent component's Font property.


RowExtent Property

Applies to

TcsNotebook component

Declaration

property RowExtent: Integer;

Description

The RowExtent property is a calculated read-only property which specifies the number of rows of tabs currently displayed.  It is recalculated if the number of tabs is changed or if the TabsPerRow property is changed.


RowIndent Property

Applies to

TcsNotebook component

Declaration

property RowIndent: Integer;

Description

The RowIndent property is the indent, in pixels, added to each successive row of tabs after the first.


SaveResources Property

Applies to

TcsNotebook component

Declaration

property SaveResources: Boolean;

Description

The SaveResources property indicates whether resources will be saved by releasing the Windows handles for the components on a page when another page is selected.  Normally, the handles for the components on a Notebook page are created when the page is first shown and then only released when the form is destroyed.  If SaveResources is True then the handles for the components on a page will be released when another page is selected, thus reducing the total resources required.

Note that if SaveResources is True there may be a slight increase in how long it takes to display a new page (even if it has previously been selected) because the handles must be re-created each time the page is re-selected.


SelectedColor Property

Applies to

TcsNotebook component

Declaration

property SelectedColor: TColor;

Description

The SelectedColor property indicates the color to be used for the text of the selected tab, the default color is clBtnText.


SidewaysText Property

Applies to

TcsNotebook component

Declaration

property SidewaysText: Boolean;

Description

The SidewaysText property indicates whether tab text is to be displayed sideways when using Left or Right tab orientation.  You can only set SidewaysText to True when TabOrientation is toLeft or toRight.  Changing TabOrientation from toTop or toBottom to toLeft or toRight will automatically set SidewaysText to True.  Changing TabOrientation from toLeft or toRight to toTop or toBottom will automatically set SidewaysText to False.  When SidewaysText is True the list of fonts available when editing the TabFont property only includes TrueType fonts so that text rotation will be possible.


TabFont Property

Applies to

TcsNotebook, TTabbedNotebook component

Declaration

property TabFont: TFont;

Description

The TabFont property determines the font used on the tabs of the notebook control.  The text of the selected tab is boldfaced if the selected font for the TabFont property is not also boldfaced.

When using Left or Right oriented tabs (see TabOrientation) and SidewaysText you should use a TrueType font to get rotated text.


TabHeight Property

Applies to

TcsNotebook component

Declaration

property TabHeight: Integer;

Description

The TabHeight property determines the height, in pixels, of each tab.


TabOrientation Property

Applies to

TcsNotebook component

Declaration

property TabOrientation: TTabOrientation;

Description

The TabOrientation property determines the orientation of the tabs around the notebook pages.  If the SidewaysText property is True the tab text will be rotated when using Left and Right tab orientations.  Note that bitmaps are never rotated, regardless of  the values of the TabOrientation or BitmapAlignment properties.  Changing TabOrientation from toTop or toBottom to toLeft or toRight or from toLeft or toRight to toTop or toBottom will automatically set the SidewaysText property to the appropriate default value.


TTabOrientation Type

Unit

CSNoteBk

Declaration

TTabOrientation = (toTop, toLeft, toBottom, toRight);

Description

TTabOrientation defines the possible values of the TabOrientation property.


TabsPerRow Property

Applies to

TcsNotebook, TTabbedNotebook component

Declaration

property TabsPerRow: Integer;

Description

The TabsPerRow property determines how many tabs will appear in each row of tabs for the TcsNotebook control.  The default value is 3.  The appropriate number of rows of tabs will be created to allow for all tabs to be displayed using the TabsPerRow value.  If TabsPerRow is greater than the actual number of tabs the size of the tabs will be reduced accordingly; this is similar to changing the MaxTabWidth property.


TextAlignment Property

Applies to

TcsNotebook component

Declaration

property TextAlignment: TTextAlignment;

Description

The TextAlignment property determines where the tab’s caption text will be placed on the tab. Note that the different text alignment options are always regarded as though you are viewing the tab in Top orientation, doing the stated text alignment, and then rotating the tab.


TTextAlignment Type

Unit

CSNoteBk

Declaration

TTextAlignment = (taLeftTop, taCentreTop, taCenterTop, taRightTop, taLeftMiddle, taCentreMiddle, taCenterMiddle, taRightMiddle, taLeftBottom, taCentreBottom, taCenterBottom, taRightBottom);

Description

TTextAlignment defines the possible values of the TextAlignment property.


UnselectedColor Property

Applies to

TcsNotebook component

Declaration

property UnselectedColor: TColor;

Description

The UnselectedColor property indicates the color to be used for the text of the unselected tabs, the default color is clBtnText.


UnselectedTabColor Property

Applies to

TcsNotebook component

Declaration

property UnselectedTabColor: TColor;

Description

The UnselectedTabColor property indicates the color used for the background of the unselected tabs.  The UnselectedTabColor property is only relevant when the UseUnselectedTabColor property is True.  All tabs will have the same background color when UseUnselectedTabColor is False.


UseUnselectedTabColor Property

Applies to

TcsNotebook component

Declaration

property UseUnselectedTabColor: Boolean;

Description

The UseUnselectedTabColor property determines whether the value of the UnselectedTabColor property will be used for the background color of the unselected tabs.  When UseUnselectedTabColor is False all the tabs will have the same background color regardless of the UnselectedTabColor value.  Also note that the UnselectedTabColor property is always ignored if there is more than one row of tabs and AnchoredTabs is True, even if UseUnselectedTabColor is True.


OnPageChanged Event

Applies to

TcsNotebook, TNotebook component

Declaration

property OnPageChanged: TNotifyEvent;

Description

The OnPageChanged event occurs immediately after a new page has been made the current page.


OnPageChanging Event

Example

Applies to

TcsNotebook component

Declaration

property OnPageChanging: TPageChangingEvent;

Description

The OnPageChanging event is sent before a new page is made the current page.  Use the OnPageChanging event handler if you want to prevent a change to a new page, for example when certain validation conditions are not met for the current page.  To perform processing after changing to a new page use the OnPageChanged event.


OnPageChanging Event Example

The following example shows how to prevent a change to a new page if certain conditions are not met.

procedure TForm1.csNotebook1PageChanging(Sender: Tobject;

NewIndex: Integer; var AllowChange: Boolean);

begin

  if not PageIsValid(csNotebook1.PageIndex) then

    AllowChange := False;

end;

function TForm1.PageIsValid(Index: Integer): Boolean;

begin

  case Index of

    0: Result := (Length(Name.Text) > 0);

    1: Result := (Length(Address.Text) > 0);

  end;

end;


TPageChangingEvent Type

See also

Unit

CSNoteBk

Declaration

TPageChangingEvent = procedure(Sender: TObject; NewIndex: Integer;                                var AllowChange: Boolean) of object;

Description

The TPageChangingEvent type points to a method that is called before a new page is selected.  NewIndex indicates the PageIndex value of the page which is about to be selected.  The AllowChange variable indicates if it is permissable to select the new page.  If AllowChange is False the new page will not be selected.


See Also

OnPageChanging


OnTabClick Event

Applies to

TcsNotebook component

Declaration

property OnTabClick: TNotifyEvent;

Description

An OnTabClick event occurs when the user selects a tab using one of the following techniques:

(1) pressing the primary mouse button while the mouse pointer is over the tab

(2) pressing the appropriate accelerator key for a tab (as for buttons)

(3) using the arrow keys when the tab has a focus rectangle

An OnTabClick event will not occur if the OnPageChanging event handler prevents the change to the new page.

An OnTabClick event will not occur if a tab is selected programmatically, for example when the ActivePage or PageIndex properties are assigned new values in source code.  To respond to a page being made current (regardless of whether the user selected it or it was selected in source code) use the OnPageChanged event instead.  The OnTabClick event, when it does occur, will occur after the OnPageChanged event.


Classic Software
TcsNotebook Support

Getting Support

Support for TcsNotebook can be obtained from Classic Software via:

CompuServe ID:	100033,1230

Telephone/Fax:	+61 9 271 5407	(9:00am-5:00pm WST)

Mail:	Unit 2/19A Wood Street

INGLEWOOD  WA  6052

AUSTRALIA

Please note that the times for telephone support are for Australian Western Standard Time.


Country Code	Area Code (WA)	Telephone No.

61	9	271 5407


Notebook Editor for TcsNotebook
Notebook Tabs Editor

Use the Notebook Tabs editor to add, edit, delete or move tabs in a TcsNotebook component.  The editor shows the Caption, Help Context and whether a bitmap has been assigned for each tab and also the bitmap for the highlighted row of the list of tabs.

Opening the Notebook Tabs Editor:

Select the TcsNotebook component on the form and then use one of the following techniques:

·	press the secondary mouse button while the mouse pointer is positioned over the form and then choose the Edit Tabs command

·	click the ellipsis button in the Value column for the Pages property

·	double click in the Value column for the Pages property

·	press Ctrl+Enter after moving to the Value column for the Pages property

Edit Button

Choose the Edit button to edit the Caption, Help Context or Bitmap of an existing tab.  The Edit Tab dialog box will be displayed.

Add Button

Choose the Add button to add a new tab.  The Add Tab dialog box will be displayed.  New tabs are always added to the end of all existing tabs.  If you want to insert a new tab you can add it and then use the Move button to change its position in the list of tabs.

Delete Button

Choose the Delete button to delete an existing tab.  You will be asked to confirm that you want to delete the highlighted tab.

Up/Down Buttons

Choose the Up or Down buttons to change the position of an existing tab.

Choose OK or press Esc to close the editor.


Edit Tab Dialog Box

Applies to

TcsNotebook

Use the Edit Tab dialog box to edit the details for an existing tab in a TcsNotebook control.  The Caption can contain an ampersand prefix to indicate the letter to be underlined.

Bitmaps

Choose the Bitmap button to select a bitmap using the Picture Editor dialog box.  If you want to assign a bitmap from a resource file to a tab you will have to do this at run-time using code.  See Bitmaps for TcsNotebook Pages for an example.


Add Tab Dialog Box

Applies to

TcsNotebook

Use the Add Tab dialog box to add the details for a new tab in a TcsNotebook control.  Refer to the Edit Tab Dialog Box for more information.


TcsPage Component

See also	Properties

A TcsPage component is used for each page of a TcsNotebook component.


See Also

Pages

TabBitmap

TabCaption

TabPageIndex


Properties

Bitmap


TcsPage Component
Bitmap Property

Applies to

TcsPage

Declaration

property Bitmap: TBitmap;

Description

The Bitmap property allows access to the bitmap currently assigned to the page.


TabBitmap Property

Applies to

TcsNotebook component

Declaration

property TabBitmap[Index: Integer]: TBitmap;

Description

Run-time only.  The TabBitmap property gives you access to the bitmap for each tab.  The Index value corresponds to the tab's page number.  TabBitmap will return nil if the Index value is out of range.

Note that:

csNotebook1.TabBitmap[0].LoadFromFile('map.bmp');

is equivalent to:

TcsPages(csNotebook1.Pages.Objects[0]).Bitmap.LoadFromFile('map.bmp');


TabCaption Property

Applies to

TcsNotebook component

Declaration

property TabCaption[Index: Integer]: String;

Description

Run-time only.  The TabCaption property gives you access to the caption text for each tab.  The Index value corresponds to the tab's page number.  TabCaption will return an empty string if the Index value is out of range.

Note that:

csNotebook1.TabCaption[0] := 'Tab 0';

is equivalent to:

TcsPages(csNotebook1.Pages.Objects[0]).Caption := 'Tab 0';


TabPageIndex Property

Applies to

TcsNotebook component

Declaration

property TabPageIndex[const TabIdentity: String]: Integer;

Description

Run-time only.  The read-only TabPageIndex property allows you to determine the page number of the tab with the specified identity.  TabPageIndex will return -1 if no tab exists with the specified identity.